﻿Imports Gecko
Public Class Form1
    Dim geckoFX As Gecko.GeckoWebBrowser = New Gecko.GeckoWebBrowser()
    Dim xrPath As String = System.Reflection.Assembly.GetExecutingAssembly.Location
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        xrPath = xrPath.Substring(0, xrPath.LastIndexOf("\") + 1) & "xulrunner"
        Gecko.Xpcom.Initialize(xrPath)
        Gecko.GeckoPreferences.Default("extensions.blocklist.enabled") = False
        GeckoWebBrowser3.Navigate("www.duckduckgo.com")
    End Sub
    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        Try
            Dim tab As New TabPage
            Dim brws As New GeckoWebBrowser
            brws.Dock = DockStyle.Fill
            tab.Text = "New Tab"
            tab.Controls.Add(brws)
            Me.TabControl1.TabPages.Add(tab)
            Me.TabControl1.SelectedTab = tab
            brws.Navigate("")
        Catch ex As Exception
        End Try
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        CType(TabControl1.SelectedTab.Controls.Item(0), GeckoWebBrowser).GoBack()
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        CType(TabControl1.SelectedTab.Controls.Item(0), GeckoWebBrowser).GoForward()
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        CType(TabControl1.SelectedTab.Controls.Item(0), GeckoWebBrowser).Refresh()
    End Sub
    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Try
            CType(TabControl1.SelectedTab.Controls.Item(0), GeckoWebBrowser).Navigate(TextBox1.Text)
        Catch ex As Exception
        End Try
    End Sub
    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        TabControl1.Controls.Remove(TabControl1.SelectedTab)
    End Sub
    Private Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click
        CType(TabControl1.SelectedTab.Controls.Item(0), GeckoWebBrowser).Stop()
    End Sub
    Private Sub TextBox2_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TabControl1.KeyDown
        If e.KeyCode = Keys.T AndAlso e.Control = True Then
            Try
                Dim tab As New TabPage
                Dim brws As New GeckoWebBrowser
                brws.Dock = DockStyle.Fill
                tab.Text = "New Tab"
                tab.Controls.Add(brws)
                Me.TabControl1.TabPages.Add(tab)
                Me.TabControl1.SelectedTab = tab
                brws.Navigate("")
            Catch ex As Exception
            End Try
        End If
    End Sub
    Private Sub Button8_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        Try
            CType(TabControl1.SelectedTab.Controls.Item(0), GeckoWebBrowser).Navigate(TextBox1.Text)
        Catch ex As Exception
        End Try
    End Sub
    Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TabControl1.KeyDown
        If e.KeyCode = Keys.F4 AndAlso e.Control = True Then
            TabControl1.Controls.Remove(TabControl1.SelectedTab)
        End If
    End Sub
    Private Sub TextBox9_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TabControl1.KeyDown
        If e.KeyCode = Keys.F5 = True Then
            CType(TabControl1.SelectedTab.Controls.Item(0), GeckoWebBrowser).Refresh()
        End If
    End Sub
End Class

